import React from 'react';
import { Form, Input, Button, Row, Col } from 'antd';
import css from './login.less';
import { myPost } from '../../util/api';

class Login extends React.Component {
    constructor(props) {
        super(props);
        this.state = { username: undefined, password: undefined };
    }

    onFinish = values => {
        console.log('Success:', values);
        myPost('h5/activity/findActivityDetail').then(result =>{
            console.log(result)
        })
        this.props.history.push({pathname:'/index', query:{id:3}})
    };

    onFinishFailed = errorInfo => {
        // console.log('Failed:', errorInfo);
    };


    render() {
        const layout = {
            labelCol: {
                span: 8,
            },
            wrapperCol: {
                span: 14,
            },
        };
        const tailLayout = {
            wrapperCol: {
                offset: 8,
                span: 16,
            },
        };

        return (
            <Row >
                <Col span={8} offset={8}>
                    <Form
                        {...layout}
                        name="basic"
                        initialValues={{
                            remember: true,
                        }}
                        onFinish={this.onFinish}
                        onFinishFailed={this.onFinishFailed}
                    >
                        <Form.Item
                            label="账号"
                            name="username"
                            rules={[
                                {
                                    required: true,
                                    message: 'Please input your username!',
                                },
                            ]}
                        >
                            <Input />
                        </Form.Item>

                        <Form.Item
                            label="密码"
                            name="password"
                            rules={[
                                {
                                    required: true,
                                    message: 'Please input your password!',
                                },
                            ]}
                        >
                            <Input.Password />
                        </Form.Item>

                        <Form.Item {...tailLayout}>
                            <Button type="primary" htmlType="submit">
                                登录
          </Button>
                        </Form.Item>
                    </Form>
                </Col>
            </Row>)
    }
}

export default Login;